from django.shortcuts import render
from cars.models import Info
# Create your views here.

# 访问首页
def index(request):
    uname = request.COOKIES.get('username')
    print(uname)

    return render(request, "index.html",{'uname':uname})

def buy(request):

    content = {'cars_result':Info.objects.all()}
    print(Info.objects.filter())
    return render(request, 'buy.html', content)


def detail(request,car_id):
    content = {'car_result':Info.objects.get(id=car_id)}
    return render(request, 'car.html', content)
